<table<?
/* @author Udo Schroeter <udo.schroeter@gmail.com>
 * @license dual license: LGPL / commercial use license
 */ 

$inventory = $this->character->getInventory();
$bonuses = array();
foreach ($inventory as $invDS)
{
  $props = textToStringList($invDS['i_properties']);
  foreach($props as $k => $v)
  {
    $type = CutSegment('.', $k); 
    if ($type == 'stats' || $type == 'owner')
    {
      $bonuses[$k]['amount'] += $v;
      $bonuses[$k]['items'][] = $invDS['i_name'].' ('.$v.')';
    }
  } 
}

foreach($this->character->stats as $k => $v)
{
  if (substr($k, -6) == '.magic')
  {
    $bonusType = substr($k, 0, -6);
    $bonuses[$bonusType]['amount'] += $v;
    $bonuses[$bonusType]['items'][] = '<b>Spell ('.$v.')</b>';
  }
}

ksort($bonuses);
foreach($bonuses as $bonusType => $bon)
{
  $vz = ''; if ($bon['amount'] > 0) $vz = '+';
  ?><tr>
    <td valign="top"><?= AGController::l10n($bonusType, 'cq') ?></td>
    <td valign="top"><div align="right"><?= $vz.$bon['amount'] ?></div></td>
    <td valign="top"><?= implode(', ', $bon['items']) ?></td>
  </tr><?
}
?></table>
<?

?>